package org.bees.cms.core.clause;

import javax.persistence.Column;
import javax.persistence.Entity;

@Entity
public class Restriction extends Clause {
	private static final long serialVersionUID = 4391417932081836191L;

	private Integer current;
	private Integer capacity;

	@Override
	public String toSQL(Adapter adapter, Class<?> mapper, String alias) throws Exception {
		return "LIMIT " + ((current - 1) * capacity) + "," + capacity;
	}

	@Column(nullable = false)
	public Integer getCurrent() {
		return current;
	}

	public void setCurrent(Integer current) {
		this.current = current;
	}

	@Column(nullable = false)
	public Integer getCapacity() {
		return capacity;
	}

	public void setCapacity(Integer capacity) {
		this.capacity = capacity;
	}

}
